<?php

function select_list($data, $currValue = null, $name = 'name', $value = 'value') {
  foreach ($data as $key => $item) {
    $selected = '';
    if ($currValue != null && $item[$value] == $currValue) {
      $selected = ' selected="selected"';
    }
    echo "<option value=\"{$item[$value]}\"{$selected}>{$item[$name]}</option>";
  }
}

function get_file_full_url($path) {
  if (strpos($path, "http") === 0) {
    return $path;
  } else {
    $root = cmf_get_domain() . cmf_get_root();
    if (strpos($path, "/") === 0) {
      return $root . $path;
    } else {
      return $root . '/' . $path;
    }
  }
}
